package com.jason.weibosender.util;

import java.util.List;

import com.jason.weibosender.ui.CodeFrame;

import weibo4j.Friendships;
import weibo4j.Oauth;
import weibo4j.http.AccessToken;
import weibo4j.model.User;
import weibo4j.model.UserWapper;
import weibo4j.model.WeiboException;

public class TokenCheckerHelper extends BaseHelper {
	public static long checkTokenAvaliableTime(String accessTokenStr){
		Oauth oauth = new Oauth();
		long size = -1;
		AccessToken accessToken = null;
		try {
			accessToken = oauth.getAccessTokenInfoByAccessToken(accessTokenStr);
		} catch (WeiboException e) {
			new CodeFrame();
		}
		if(accessToken != null){
			Friendships friendShips = new Friendships();
			friendShips.client.setToken(accessTokenStr);
			try {
				UserWapper users = friendShips.getFollowersById(accessToken.getUid());
				size = users.getTotalNumber();
			} catch (WeiboException e1) {
				new CodeFrame();
			}
		}
		return size;
	}
}
